package com.baseproject.entity;

import android.text.TextUtils;

import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

/**
 * @version V1.0  16/9/10下午4:39
 * @author:OliverTan(www.tandunzhao.cn)
 */
public class User implements Serializable {

    private String username;
    private String password;
    private String loginType;

    private int id;
    private String headImageUrl;
    private String nickName;

    public User() {

    }

    public User(int id, String headImageUrl, String nickName) {
        this.id = id;
        this.headImageUrl = headImageUrl;
        this.nickName = nickName;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getLoginType() {
        return loginType;
    }

    public void setLoginType(String loginType) {
        this.loginType = loginType;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getHeadImageUrl() {
        return headImageUrl;
    }

    public void setHeadImageUrl(String headImageUrl) {
        this.headImageUrl = headImageUrl;
    }

    public String getNickName() {
        try {
            return URLDecoder.decode(nickName, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return null;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public boolean isValid() {
        return getId() >= 0 && !TextUtils.isEmpty(getHeadImageUrl()) && !TextUtils.isEmpty(getNickName());
    }

}
